package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：战神阿信
 * @date ：Created in 2022年06月09日
 * @description ：
 * @version: 1.0
 */
@RestController
@Slf4j
@RequestMapping("/mobile")
public class MobileSetmealController {
    @Autowired
    private SetMealService setMealService;
    @GetMapping("/setmeal/getSetmeal")
    public Result getSetmeal(){
        log.info("查询所有套餐");
        List<Setmeal> Setmeals=setMealService.findAll();
        return new Result(true, MessageConst.GET_SETMEAL_LIST_SUCCESS,Setmeals);
    }
    /**
     * 套餐详情
     * @param id
     * @return
     */
    @GetMapping("/setmeal/findById")
    public Result findById(Integer id){
        log.info("[套餐查询]");
        Setmeal setmeal = setMealService.findById(id);
        return new Result(true, MessageConst.ACTION_SUCCESS,setmeal);
    }

}
